2
2
.
.
1
1
.
.
2
2
A
A
u
u
t
t
o
o
I
I
m
m
p
p
o
o
r
r
t
t
I
I
n
n
f
f
o
o
This tutorial shows how to setup Android Studio to automatically add import statements for used Classes.
Content
Auto Import (it will automatically import Class if only one Package contains Class with such name)
Select Import (if multiple packages contain Class with given name you need to select correct Package)
Exclude Package (you can exclude Packages in which Auto Import looks for Class with given name)
Include Package (you can include Packages in which Auto Import looks for Class with given name)
A
A
u
u
t
t
o
o
I
I
m
m
p
p
o
o
r
r
t
t
File
Settings
Editor
General
Auto Import
Insert imports on paste: All
Add unambiguous imports on the fly: CHECK
Optimize imports on the fly: CHECK
OK
Automatically import Classes
S
S
e
e
l
l
e
e
c
c
t
t
I
I
m
m
p
p
o
o
r
r
t
t
If multiple packages contain given Class you need to hover over a Class name and press import link.
Then you need to select package from which you want to import the Class.
Hover over Class - Import
Select Import
E
E
x
x
c
c
l
l
u
u
d
d
e
e
P
P
a
a
c
c
k
k
a
a
g
g
e
e
If multiple packages contain given Class you need to hover over a Class name and press import link.
You will then get a list of packages that contain Class with that name.
You can now exclude some of these packages from Auto Import by clicking on the arrow on the right.
This will give you options to exclude just the Class or the whole package or just part of package hierarchy.
When you exclude Class there will be a popup showing General - Auto Import Settings with the list of all excluded classes.
You can use these Settings to put back the classes as shown next.
Exclude Import
I
I
n
n
c
c
l
l
u
u
d
d
e
e
P
P
a
a
c
c
k
k
a
a
g
g
e
e
If you have excluded some Classes from Auto Import you can reverse that by using General - Auto Import Settings.
There you will get a list of all excluded Packages and you can select Package and remove it from the list.
P
P
r
r
o
o
c
c
e
e
d
d
u
u
r
r
e
e
File
Settings
Editor
General
Auto Import
Include Class